import request from '@/axios'

export interface SysMenu {
  menuId?: number
  menuParentId?: number
  menuName: string
  menuCode: string
  menuRoute: string
  menuType: string
  menuIcon?: string
  ordinal?: number
  isEnabled?: boolean
  openType?: string
  remark?: string
}

export interface MenuDTO {
  menuId?: number
  menuParentId?: number
  menuName: string
  menuCode: string
  menuRoute: string
  menuType: string
  menuIcon?: string
  ordinal?: number
  openType?: string
  children?: MenuDTO[]
}

// 获取菜单树
export const getSysMenuListApi = () => {
  return request.get({ url: '/api/system/menu/listMenuTree' })
}

// 获取菜单详情
export const getSysMenuDetailApi = (id: number) => {
  return request.get({ url: `/api/system/menu/get`, params: { menuId: id } })
}

// 新增或更新菜单
export const saveOrUpdateSysMenuApi = (data: SysMenu) => {
  return request.post({ url: '/api/system/menu/saveOrUpdate', data })
}

// 删除菜单
export const deleteSysMenuApi = (id: number) => {
  return request.get({ url: '/api/system/menu/delete', params: { menuId: id } })
}

// 获取个人菜单
export const getPersonalMenuTreeApi = () => {
  return request.get({ url: '/api/system/menu/listPersonalMenuTree' })
}
